unit uMainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls;

type
  TForm1 = class(TForm)
    web1: TWebBrowser;
    Memo1: TMemo;
    btnOpen: TButton;
    Edit1: TEdit;
    Button1: TButton;
    btnGo: TButton;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure btnGoClick(Sender: TObject);
    procedure btnOpenClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  IdHTTP;
  
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.Add(
    web1.OleObject.Document.cookie
    )
end;

procedure TForm1.btnGoClick(Sender: TObject);
var
  idHttp: TIdHTTP;
  exprStr, url: string;
  startId, endId: Integer;
begin
  idHttp := TIdHTTP.Create(nil);
  idHttp.HandleRedirects := True;
  try
    url := Edit2.Text;
    exprStr := '';
    startId := 0;
    endId := 0;
    if (Pos('[', url)>0) and
       (Pos(']', url) < Pos('[', url)) then
    begin
      exprStr := Copy(url, Pos('[', url), Pos('[', url)-Pos('[', url));
      //exprStr := Copy(url, startId+1, endId-startId);
    end;
    idHttp.Request.CustomHeaders.Values['Cookie'] := web1.OleObject.Document.cookie;
    Memo1.Lines.Add(
      idHttp.Get('http://116.255.170.106/4y.asp?id=1102260048')
      )
  finally
    idHttp.Free;
  end;
end;

procedure TForm1.btnOpenClick(Sender: TObject);
begin
  web1.Navigate(Edit1.Text);
end;

end.
